package com.example.demoeasyexcelboot.dto;

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.format.NumberFormat;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.example.demoeasyexcelboot.convert.GenderConverter;
import jakarta.validation.constraints.NotBlank;
import lombok.*;

import java.io.Serializable;
import java.util.Date;

/**
 * @author: FSL
 * @date: 2023/4/12
 * @description: 映射实体类，注意：不要用@Accessors注解，会导致导入表数据为null
 */
@Builder
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class UserDto implements Serializable {
    @ExcelProperty("用户编号")
    @ColumnWidth(20)
    private Long id;

    @ExcelProperty("所属组id")
    @ColumnWidth(20)
//    @ExcelMerge(merge = true)
    private Long groupId;

    @ExcelProperty("用户名")
    @ColumnWidth(20)
    @NotBlank(message = "username不能为空")
//    @ExcelMerge
    private String username;

    @ExcelProperty("出生日期")
    @ColumnWidth(20)
    @DateTimeFormat("yyyy-MM-dd HH:mm:ss")
    private Date birthday;

    @ExcelProperty({"联系方式","电话号码"})
    @ColumnWidth(20)
//    @ExcelMerge
    private String phone;

    @ExcelProperty({"联系方式","邮箱"})
    @ColumnWidth(20)
    private String email;

    @ExcelProperty("身高")
    @NumberFormat("#.##")
    @ColumnWidth(20)
    private Double height;

    @ExcelProperty(value = "性别",converter = GenderConverter.class)
    @ColumnWidth(10)
    private Integer gender;
}
